package cn.gs.util.set;

// @author gs
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

public class ArrayUtil {

    public static double[] longs2doubles(long... num) {
        if (null == num) {
            return null;
        }
        double[] ret = new double[num.length];
        for (int i = 0; i < num.length; ++i) {
            ret[i] = num[i];
        }
        return ret;
    }

    public static double[] ints2doubles(int... num) {
        if (null == num) {
            return null;
        }
        double[] ret = new double[num.length];
        for (int i = 0; i < num.length; ++i) {
            ret[i] = num[i];
        }
        return ret;
    }

    public static List<Integer> array2List(int... ids) {
        List<Integer> list = new ArrayList<Integer>(ids.length);
        for (int i = 0; i < ids.length; ++i) {
            list.add(ids[i]);
        }
        return list;
    }

    public static int[] collection2Array(Collection<Integer> ids, int def) {
        int[] list = new int[ids.size()];
        int i = 0;
        for (Integer ii : ids) {
            list[i++] = null == ii ? def : ii;
        }
        return list;
    }

    public static int[] collection2Array(Collection<Integer> ids) {
        return collection2Array(ids, 0);
    }
}